package com.example.socialmediaplatform.model;

public class OutputMessage {
    private String from;
    private String message;
    private String time;
    private boolean myMsg;
    
    // 新增字段以支持新的消息格式
    private String fromUser;
    private String content;
    private String createdAt;
    private String type;

    public OutputMessage(String from, String message, String time, boolean myMsg) {
        this.from = from;
        this.message = message;
        this.time = time;
        this.myMsg = myMsg;
        // 向后兼容
        this.fromUser = from;
        this.content = message;
    }

    public OutputMessage() {
    }

    public String getFrom() {
        return from;
    }

    public String getMessage() {
        return message;
    }

    public String getTime() {
        return time;
    }

    public boolean isMyMsg() {
        return myMsg;
    }
    
    // 新增getter和setter
    public String getFromUser() {
        return fromUser != null ? fromUser : from;
    }
    
    public void setFromUser(String fromUser) {
        this.fromUser = fromUser;
        this.from = fromUser; // 保持向后兼容
    }
    
    public String getContent() {
        return content != null ? content : message;
    }
    
    public void setContent(String content) {
        this.content = content;
        this.message = content; // 保持向后兼容
    }
    
    public String getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
}
